clear all
set more off
cd ""

use "sample.dta", clear

* Generate a dummy indicating high career incentive
** Age younger than 58 years, and
** Tenure in the current term more than 2 years

replace tenure = tenure - 5 if tenure > 5
gen high = age < 58 & tenure > 2 if !mi(age) & !mi(tenure)

* Generate interaction terms between time-to-event dummies and high incentive
* Transformation to get linear combinations of parameters

tab rel_time, gen(rel_w)
forvalue i = 1/31 {
gen rel_w`i'_D = rel_w`i' * high
}

gen rel_w11_D_21 = rel_w11_D*21
forvalue i = 12/31 {
gen diff_Drel`i'_11 = rel_w`i'_D - rel_w11_D
}

**********
* Panel A
**********

reghdfe in_confn14 rel_w11_D_21 diff_Drel* treat_csm wdsp temp prcp if faction == 1, absorb(i.city_code#i.high i.time#i.high i.prov_code#c.time#i.high) cluster(time)

reghdfe d_movewithin rel_w11_D_21 diff_Drel* treat_csm wdsp temp prcp if faction == 1, absorb(i.city_code#i.high i.time#i.high i.prov_code#c.time#i.high i.prov_code#c.time2#i.high) cluster(time)

reghdfe bdindexS7_std rel_w11_D_21 diff_Drel* treat_csm wdsp temp prcp if faction == 1, absorb(i.city_code#i.high i.time#i.high i.prov_code#c.time#i.high) cluster(time)

**********
* Panel B
**********

reghdfe in_confn14 rel_w11_D_21 diff_Drel* treat_csm wdsp temp prcp if faction == 0, absorb(i.city_code#i.high i.time#i.high i.prov_code#c.time#i.high) cluster(time)

reghdfe d_movewithin rel_w11_D_21 diff_Drel* treat_csm wdsp temp prcp if faction == 0, absorb(i.city_code#i.high i.time#i.high i.prov_code#c.time#i.high i.prov_code#c.time2#i.high) cluster(time)

reghdfe bdindexS7_std rel_w11_D_21 diff_Drel* treat_csm wdsp temp prcp if faction == 0, absorb(i.city_code#i.high i.time#i.high i.prov_code#c.time#i.high) cluster(time)
